<?php

class Database {

    const serverDB = "mysql:host=127.0.0.1; port=3306; dbname=sistema.estoque";
    const username = "root";
    const password = "";

    private $connect = NULL;
    private static $instance;

    public static function conectar() {

        if (!isset(self::$instance)) {

            self::$instance = new PDO(self::serverDB, self::username, self::password, 
                              array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
        }

        return self::$instance;
    }

    function __destruct() {
        $this->connect = NULL;
    }
}
